<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <title>修改地址</title>
    <link rel="stylesheet" href="__PUBLIC__css/reset.css" />
    <link rel="stylesheet" href="__PUBLIC__css/store.css" />
</head>
<body>
<div class="layout">
    <!--header-->
    <div class="wrapper">
        <div class="header">
            <a class="s_preson" href="{:U('Users/address')}" target="_blank"> < </a>
            <div class="store">
                <span>修改地址</span>
            </div>
            <div class="s_preson_right">
                <i class="s_icon s_preson_right_btn"></i>
            </div>
        </div>
    </div>

    <form action="{:U('Users/updataAddress')}" method="POST" name="updataAddressForm" onsubmit="return verify()">
        <div class="add-address">
            <ul>
                <li><input type="hidden" value="{$addressInfo.id}" name="id" /></li>
                <li><span>姓        名：</span><input type="text" class="addTips" name="name" value="{$addressInfo.consignee}"/></li>
                <li><span>手        机：</span><input type="text" class="addTips" name="tel" value="{$addressInfo.tel}"/></li>
                <!--<li><span>已        选：</span>{$addressInfo.provinceName} \ {$addressInfo.cityName} \ {$addressInfo.zoneName}</li>-->
                <!--<li>-->
                    <!--<span>省        份：</span>-->
                    <!--<select class="select" name="province" onchange="addCity(this.value)">-->
                        <!--<option value="">请选择：</option>-->
                        <!--<volist name="province" id="ao">-->
                            <!--<option value="{$ao.region_id}">{$ao.region_name}</option>-->
                        <!--</volist>-->
                    <!--</select>-->
                    <!--<label>﹀</label>-->
                    <!--<em>(必填)</em>-->
                <!--</li>-->
                <!--<li>-->
                    <!--<span>市        区：</span>-->
                    <!--<select class="select" name="city" id="city" onchange="addZone(this.value)">-->
                        <!--<option value="">请选择：</option>-->

                    <!--</select>-->
                    <!--<label>﹀</label>-->
                    <!--<em>(必填)</em>-->
                <!--</li>-->
                <!--<li>-->
                    <!--<span>区县街道：</span>-->
                    <!--<select class="select" name="zone" id="zone">-->
                        <!--<option value="">请选择：</option>-->

                    <!--</select>-->
                    <!--<label>﹀</label>-->
                    <!--<em>(必填)</em>-->
                <!--</li>-->
                <li>
                    <span>市        区：</span>
                    <select class="select" name="city" id="city" onchange="addZone(this.value)">
                        <option value="52" selected="selected">北京(仅限北京地区)</option>
                    </select>
                    <label>﹀</label>
                    <em>(必填)</em>
                </li>
                <li>
                    <span>区县街道：</span>
                    <select class="select" name="zone" id="zone">
                        <option value="{$addressInfo.zoneID}" selected="selected">{$addressInfo.zoneName}</option>
                        <option value="500">东城区</option>
                        <option value="501">西城区</option>
                        <option value="502">海淀区</option>
                        <option value="503">朝阳区</option>
                        <option value="504">崇文区</option>
                        <option value="505">宣武区</option>
                        <option value="506">丰台区</option>
                        <option value="507">石景山区</option>
                        <option value="508">房山区</option>
                        <option value="509">门头沟区</option>
                        <option value="510">通州区</option>
                        <option value="511">顺义区</option>
                        <option value="512">昌平区</option>
                        <option value="513">怀柔区</option>
                        <option value="514">平谷区</option>
                        <option value="515">大兴区</option>
                        <option value="516">密云县</option>
                        <option value="517">延庆县</option>
                    </select>
                    <label>﹀</label>
                    <em>(必填)</em>
                </li>
                <li><span>详细地址：</span><input type="text" class="addTips" name="address" value="{$addressInfo.address}"/></li>
            </ul>
            <input type="submit" class="mian-address-btn" value="完成">
        </div>
    </form>
    <div class="footer">
        <p>©2015 北京食安城信息科技有限公司，并保留所有权利</p>
    </div>
</div>
</body>
<script type="text/javascript" src="__PUBLIC__js/jquery.min.js" ></script>
<script>

    function verify()
    {

        var myreg = /^(((13[0-9]{1})|159|153)+\d{8})$/;
        var tel=document.addAddressForm.tel.value;

        if(document.addAddressForm.name.value=="")
        {
            alert("姓名不能为空!");
            document.addAddressForm.name.focus();
            return false;
        }
        else if(document.addAddressForm.name.value.length>50)
        {
            alert("姓名字数为25");
            document.addAddressForm.name.focus();
            return false;
        }
        else if(!myreg.test(tel))
        {
            alert("手机号格式不正确!");
            document.addAddressForm.tel.focus();
            return false;
        }
        else if(document.addAddressForm.zone.value=="")
        {
            alert("请选择地区!");
            document.addAddressForm.zone.value.focus();
            return false;
        }
    }

    function addCity(province)
    {
        $.ajax({
            url:"{:U('Users/city')}",
            type:"POST",
            data:{
                id:province
            },
            dataType:"html",
            timeOut:"1000",
            error: function(){alert('Error loading PHP document');},
            success: function(result){
                $("#city").append(result);
            }
        });
    }

    function addZone(city_id)
    {
        $.ajax({
            url:"{:U('Users/zone')}",
            type:"POST",
            data:{
                id:city_id
            },
            dataType:"html",
            timeOut:"1000",
            error: function(){alert('Error loading PHP document');},
            success: function(result){
                $("#zone").append(result);
            }
        });
    }
</script>
</html>

